﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 控制台测试.Service
{
    public class UserService
    {
        private static readonly UserService instance;

        private UserService() { }

        /// <summary>
        /// 懒加载
        /// 当UserService 的属性或方法被调用时，静态的构造函数就会被调用。
        /// </summary>
        static UserService()
        {
            Console.WriteLine("构造函数开始执行");
            instance = new UserService();
            Console.WriteLine(instance.GetHashCode());
        }

        public static void SayHello()
        {
            string str = "HelloWorld";
        }
    }
}
